
//
//  TSUserViewController.m
//  chart
//
//  Created by xu on 15/8/16.
//  Copyright (c) 2015年 xu. All rights reserved.
//

#import "TSUserViewController.h"
#import "TSUserListTableView.h"
#import "TSCreateScheduleViewController.h"

@interface TSUserViewController ()

@end

@implementation TSUserViewController{
    TSUserListTableView *tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshUserViewController:) name:TSNotification_ScheduleCreateSucceeded object:nil];
    
    self.navigationItem.title = @"个人日程";
    
    WS(weakSelf);
    [self rightBarButtonWithTitle:nil barNorImage:[UIImage imageNamed:@"topic_follow_add"] barHltImage:nil action:^{
        [weakSelf onRightBarBarButtonClick];
    }];
    
    tableView = [[TSUserListTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.view addSubview:tableView];
}

- (void)refreshUserViewController:(NSNotification *)noti
{
    if (tableView) {
        [tableView.header beginRefreshing];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)onRightBarBarButtonClick
{
    TSCreateScheduleViewController *schedule_vc = [[TSCreateScheduleViewController alloc] init];
    TSBaseNavigationController *nav = [[TSBaseNavigationController alloc] initWithRootViewController:schedule_vc];
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}




@end
